<?php

class Crypt {

    public static function &factory($driver, $params = array()) {
        $class = 'Crypt_' . $driver;
        if (class_exists($class)) {
            $obj = new $class($params);
            return $obj;
        } else {
            throw new Yaf_Exception('Unable to find class for driver ' . $driver);
        }
    }

    /**
     * encrypt
     * 加密
     * 
     * @param  string $string 要加密的字符串
     * @return string
     */
    public function encrypt($string, $key) {
        throw new Yaf_Exception('method not defined');
    }

    /**
     * decrypt
     * 解密
     * 
     * @param  string $string 要加密的字符串
     * @return string
     */
    public function decrypt($string, $key) {
        throw new Yaf_Exception('method not defined');
    }

}
